<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>My JSP 'ReturnCom.jsp' starting page</title>
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/base.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/info-mgt.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/WdatePicker.css" />

		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/common.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/WdatePicker.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.pagination.js"></script>
	</head>
	<body>
		<div class="title">
			<h2>
				公共资源归还
			</h2>
			<form method="post"
				action="${pageContext.request.contextPath }/ComMethod.action?method=selectApplyNeedReturn">
				<div class="query">
					<div class="query-conditions ue-clear">
						<div class="conditions name ue-clear">
							<label>
								申请物品：
							</label>
							<p class="short-input ue-clear">
								<select id="selectcom" name="comname">
									<option>
										请选择
									</option>
									<c:forEach items="${requestScope.selectAll}" var="wait"
										varStatus="c">
										<option value="${wait.comName }">
											${wait.comName }
										</option>
									</c:forEach>
								</select>
							</p>
						</div>
						<div class="conditions name ue-clear">
							<label>
								申请人：
							</label>
							<p class="long-input ue-clear">
								<select id="selectuser" name="username">
									<option>
										请选择
									</option>
									<c:forEach items="${requestScope.selectAll}" var="wait"
										varStatus="c">
										<option value="${wait.userId }-${wait.username }">
											${wait.userId }-${wait.username }
										</option>
									</c:forEach>
								</select>
							</p>
						</div>
						<div class="conditions name ue-clear">
							<label>
								申请部门：
							</label>
							<p class="short-input ue-clear">
								<select id="selectdept" name="deptname">
									<option>
										请选择
									</option>
									<c:forEach items="${requestScope.selectAll}" var="wait"
										varStatus="c">
										<option value="${wait.userDept }">
											${wait.userDept }
										</option>
									</c:forEach>
								</select>
							</p>
						</div>
						<div class="query-btn ue-clear">
							<input type="submit" id="submit" value="查询" />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="reset" id="reset" value="重置">
						</div>
					</div>
				</div>
			</form>
			<div class="table-box">
				<table>
					<thead>
						<tr>
							<th class="num">
								序号
							</th>
							<th class="name">
								申请人id
							</th>
							<th class="process">
								申请人姓名
							</th>
							<th class="time">
								申请人部门
							</th>
							<th class="node">
								物品id
							</th>
							<th class="time">
								物品名称
							</th>
							<th class="time">
								申请数量
							</th>
							<th class="time">
								申请日期
							</th>
							<th class="time">
								申请使用时间段
							</th>
							<th>
								操作
							</th>
						</tr>
					</thead>
					<c:forEach items="${requestScope.waitapply.data}" var="wait"
						varStatus="c">
						<tbody>
							<tr>
								<td class="num">
									${wait.applyId }
								</td>
								<td class="name">
									${wait.userId }
								</td>
								<td class="process">
									${wait.username }
								</td>
								<td class="node">
									${wait.userDept }
								</td>
								<td class="time">
									${wait.comId }
								</td>
								<td class="time">
									${wait.comName }
								</td>
								<td class="time">
									${wait.applyComnum }
								</td>
								<td class="time">
									${wait.applyDate }
								</td>
								<td class="operate">
									${wait.startDate }-${wait.endDate }
								</td>
								<td><label style="cursor: pointer; color: blue" onclick="returnCom('${requestScope.waitapply.currentPage}','${wait.userId }','${wait.comId }','${wait.endDate }','${wait.userDept }','${wait.applyComnum }','${wait.applyId }')">归还</label></td>
							</tr>
						</tbody>
					</c:forEach>
				</table>
			</div>
		</div>
		<div>
				<table width="80%" align="center" cellspacing="0" cellpadding="0">
					<tr>
						<td>
							<a onclick=skipPage('1');;>首页</a>
						</td>
						<td>
							<a
								onclick="skipPage('${requestScope.waitapply.currentPage==1?1:requestScope.waitapply.currentPage-1 }');">上一页</a>
						</td>
						<td>
							<a
								onclick="skipPage('${requestScope.waitapply.currentPage==requestScope.waitapply.totalPage?(requestScope.waitapply.currentPage):(requestScope.waitapply.currentPage+1) }');">下一页</a>
						</td>
						<td>
							<a onclick="skipPage('${requestScope.waitapply.totalPage}');">末页</a>
						</td>
						<td>
							当前页码：${requestScope.waitapply.currentPage}/${requestScope.waitapply.totalPage}
						</td>
					</tr>
				</table>
			</div>
	</body>
	<script type="text/javascript">
		function returnCom(currentPage,userid,comid,enddate,userdept,comnum,appid){
			var a = confirm("确认归还?");
			var url = '${pageContext.request.contextPath }/ComMethod.action?method=returnCom&currPage=' + currentPage;
			url += '&username=' + document.getElementById("selectuser").value;
			url += '&deptname=' + document.getElementById("selectdept").value;
			url += '&comname=' + document.getElementById("selectcom").value;
			url += '&userid=' + userid;
			url += '&comid=' + comid;
			url += '&enddate=' +enddate;
			url += '&userdept=' +userdept;
			url += '&comnum=' +comnum;
			url += '&appid=' +appid;
			if (a) {
				window.location.href = url;
			} else {
				return false;
			}
		}
		function skipPage(currentPage) {
			var url = '${pageContext.request.contextPath }/ComMethod.action?method=selectApplyNeedReturn&currPage=' + currentPage;
			url += '&username=' + document.getElementById("selectuser").value;
			url += '&deptname=' + document.getElementById("selectdept").value;
			url += '&comname=' + document.getElementById("selectcom").value;
			window.location.href = url;
		}
	</script>
</html>
